<html>
<head><meta charset="utf-8"><title>Wide pointer layouts · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html">Wide pointer layouts</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209174910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209174910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209174910">(Sep 05 2020 at 12:04)</a>:</h4>
<p>I just noticed that <a href="https://rust-lang.github.io/unsafe-code-guidelines/layout/pointers.html#notes">https://rust-lang.github.io/unsafe-code-guidelines/layout/pointers.html#notes</a> guarantees a particular layout for side pointers (<code>dyn Trait</code> and <code>[T]</code>). Is that accurate? Seems to me like a note saying that this is not RFC'd and thus not a stable guarantee is missing?</p>



<a name="209174960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209174960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209174960">(Sep 05 2020 at 12:04)</a>:</h4>
<p>we have a catch-all clause at the root saying that this is not normative, but we do repeat this elsewhere and should likely do the same here</p>



<a name="209175237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209175237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209175237">(Sep 05 2020 at 12:13)</a>:</h4>
<p><a href="https://github.com/rust-lang/unsafe-code-guidelines/pull/249">https://github.com/rust-lang/unsafe-code-guidelines/pull/249</a></p>



<a name="209176315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209176315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209176315">(Sep 05 2020 at 12:44)</a>:</h4>
<p>not sure how much people already rely on the claim</p>



<a name="209178857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209178857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209178857">(Sep 05 2020 at 13:46)</a>:</h4>
<p>they might, nothing we can do about that</p>



<a name="209178878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209178878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209178878">(Sep 05 2020 at 13:47)</a>:</h4>
<p>there are also people relying <code>repr(Rust)</code>. but so far the compiler and lang team consider this language misuse and not a supported usecase.</p>



<a name="209181879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209181879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209181879">(Sep 05 2020 at 14:59)</a>:</h4>
<p>people rely on the layout of slices less because there's standard methods to assemble and disassemble them</p>



<a name="209181895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209181895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209181895">(Sep 05 2020 at 14:59)</a>:</h4>
<p>not to sat it doesn't happen, but it's rare and usually a beginner's mistake sort of thing</p>



<a name="209191909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209191909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209191909">(Sep 05 2020 at 19:19)</a>:</h4>
<p><a href="https://doc.rust-lang.org/stable/std/raw/struct.TraitObject.html">https://doc.rust-lang.org/stable/std/raw/struct.TraitObject.html</a> is unstable so I suspect that it should not be guaranteed in other kinds of documentation either.</p>



<a name="209191999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209191999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209191999">(Sep 05 2020 at 19:20)</a>:</h4>
<p>In fact consider just referencing this type in the documentation instead of writing down a new definition?</p>



<a name="209260829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209260829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209260829">(Sep 07 2020 at 06:20)</a>:</h4>
<p>There are good reasons to change the layout of <code>TraitObject</code> in the future, so it should definitely not have its current layout forever memorialized.</p>



<a name="209262851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209262851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209262851">(Sep 07 2020 at 06:55)</a>:</h4>
<p>There's still the plan of supporting <code>dyn Trait1+Trait2</code> some day, and layout might have to change for that</p>



<a name="209262863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide%20pointer%20layouts/near/209262863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Wide.20pointer.20layouts.html#209262863">(Sep 07 2020 at 06:55)</a>:</h4>
<p>and also do support coercions to supertraits</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>